const config = require('../../config.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    scrollHeight: "",
    xx: true,
    inter: "",
    lighth: 0,
    tabID: "1",
   
  },

  tabqh: function (e) {
    var that = this;
    var categoryId = e.currentTarget.dataset.id;
    wx.request({
      url: config.requestUrl + "/fish/findByCategoryId",
      data: { "categoryId": categoryId },
      success(res) {
        that.setData({"fishes":res.data.data});
      }
    })
    this.setData({
      tabID: categoryId,
    })
 
  },

  onLoad: function (options) {
    var that = this;
  
    that.setData({
      scrollHeight: wx.getSystemInfoSync().windowHeight
    })

    wx.request({
      url: config.requestUrl + "/fishCategory/findAll",
      success(res) {
        that.setData({"categorys":res.data.data});
        that.setData({"tabID":res.data.data[0].id});
        wx.request({
          url: config.requestUrl + "/fish/findByCategoryId",
          data: { "categoryId": res.data.data[0].id },
          success(res) {
            that.setData({ "fishes": res.data.data });
          }
        })
      }
    })

  },
  chooseFish:function(e){
    var fishId = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/fishDetails/fishDetails?fishId='+fishId,
    }) 
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
     
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})